﻿//********************************************************************************//
//创建日期：<创建日期，2016-09-23>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：修改抄表并开帐
//********************************************************************************//
using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;
using BLL.Access;
using System.Data;
using Platform.Http;
using Web.Class;
using System.Text;

namespace Web.Pages.QuShui.DiXiaS.ChaoBiaoGL
{
    public partial class XiuGaiCBBKZ : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 响应前台回调
        /// </summary>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            CallbackResult cr = new CallbackResult(e.Parameter);
            int id = this.hdCollection.Contains("ID")?Convert.ToInt32(this.hdCollection.Get("ID")):-1;
            if (e.Parameter == "search")
            {
                DataRowCollection drc = new SpHelper().P_QS_CHAOBIAOSJHQ(int.Parse(this.txtY.Text),int.Parse(this.txtM.Text),this.txtSBH.Text).Tables[0].Rows;
                if(drc.Count==0)
                {
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    cr.Msg = "无对应抄表数据,无法进行修改";
                    e.Result = cr.ToString();
                    return;
                }
                if (drc.Count >1)
                {
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    cr.Msg = "有多条重复抄表数据,请检查";
                    e.Result = cr.ToString();
                    return;
                }
                cr.IsSuccess = true;
                cr.IsAlertMsg = false;
                cr.SpecialIndetity = Convert.ToString(drc[0]["ID"]);
                cr.AddValue(Convert.ToString(drc[0]["S_YONGHUH"]), Convert.ToString(drc[0]["S_YONGHUM"]), Convert.ToString(drc[0]["S_JINGBH"]), Convert.ToString(drc[0]["I_BENYUECM"]), Convert.ToString(drc[0]["I_BENYUESL"]), Convert.ToString(drc[0]["I_SHANGYUECM"]), Convert.ToString(drc[0]["I_SHANGYUESL"]), Convert.ToString(drc[0]["I_SHUILIANG"]));
                e.Result = cr.ToString();
                return;
            }
            else if (e.Parameter == "kz")
            {
                //执行抄表数据修改
                new SpHelper().P_QS_CHAOBIAOSJXG(id, int.Parse(this.txtBenYueCM.Text), int.Parse(this.txtBenYueSL.Text));
                //重新开账该条数据
                //new SpHelper().P_QSSF_KAIZHANGDB(int.Parse(this.txtY.Text), int.Parse(this.txtM.Text), this.txtSBH.Text, BusinessTool.GetSLYMorZWNY(2, BusinessTool.WType),LoginInfo.CurrentUser.UserID.ToString());
              
                cr.IsSuccess = true;
                cr.IsAlertMsg = true;
                cr.Msg = "重新开账成功";
                e.Result = cr.ToString();
                return;
            }
        }
    }
}